﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Data.SqlClient;
using System.Text;

namespace DigDes.DS2012.DataAccess
{
    public class DislocationHistoryCommands : DataAccessBase
    {
        public SqlDataReader GetReference(string storedProcedureName)
        {
            using (var command = CreateSPCommand(storedProcedureName))
            {
                return command.ExecuteReader();
            }
        }

        public SqlDataReader GetDislocations(string fltCarNumber, int fltOperation, int fltStationOfOperation, int fltArrivalStation, int fltDepartureStation)
        {
            using (var command = CreateSPCommand("usp_Dislocations_get", GetParameters(fltCarNumber, fltOperation, fltStationOfOperation, fltArrivalStation, fltDepartureStation)))
            {
                return command.ExecuteReader();
            }
        }

        private SqlParameter[] GetParameters(string fltCarNumber, int fltOperation, int fltStationOfOperation, int fltArrivalStation, int fltDepartureStation)
        {
            return new SqlParameter[] {
                new SqlParameter("fltOperation", fltOperation),
                new SqlParameter("fltCarNumber", fltCarNumber),
                new SqlParameter("fltStationOfOperation", fltStationOfOperation),
                new SqlParameter("fltDepartureStation", fltDepartureStation),
                new SqlParameter("fltArrivalStation", fltArrivalStation)
            };
        }
    }
}